package com.lbd99.data.utils;

import java.io.Serializable;
import java.util.LinkedHashMap;
import java.util.Map;

public class AjaxJson<T> implements Serializable {
 public static final String CODE_COMMON_FAIL;
 private static final long serialVersionUID = -7790919285662399570L;
 private boolean success = true;
 private String code;
 private String msg;
 private Map<String, T> body;

 public AjaxJson() {
     this.code = "100";
     this.msg = "操作成功";
     this.body = new LinkedHashMap();
 }

public static AjaxJson returnInfo(String info) {
    AjaxJson json = new AjaxJson();
    json.setSuccess(true);
    json.setCode("100");
    json.setMsg(info);
    json.setBody(new LinkedHashMap());
    return json;
}

 public Map<String, T> getBody() {
     return this.body;
 }

 public void setBody(Map<String, T> body) {
     this.body = body;
 }

 public void put(String key, T value) {
     this.body.put(key, value);
 }

 public void remove(String key) {
     this.body.remove(key);
 }

 public String getMsg() {
     return this.msg;
 }

 public void setMsg(String msg) {
     this.msg = msg;
 }

 public boolean isSuccess() {
     return this.success;
 }

 public void setSuccess(boolean success) {
     this.success = success;
 }


 public String getCode() {
     return this.code;
 }

 public void setCode(String code) {
     this.code = code;
 }

 public String toString() {
     return "AjaxJson [success=" + this.success + ", code=" + this.code + ", msg=" + this.msg + "]";
 }

 public static AjaxJson returnExceptionInfo(String info) {
     AjaxJson json = new AjaxJson();
     json.setSuccess(false);
     json.setCode(CODE_COMMON_FAIL);
     json.setMsg(info);
     return json;
 }

 static {
     CODE_COMMON_FAIL = "101";
 }
}
